﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ChinaDynastyTours.Controls;

namespace ChinaDynastyTours.Views
{
    public partial class HotelEvaluateAnalysisForm : DevExpress.XtraEditors.XtraForm
    {
        public HotelEvaluateAnalysisForm()
        {
            InitializeComponent();
        }

        private void HotelEvaluateAnalysisForm_Load(object sender, EventArgs e)
        {
            tbCitys.Properties.DataSource = BaseInfoCtrl.GetCityData();
            tbFromDate.DateTime = DateTime.Now;
            tbToDate.DateTime = DateTime.Now.AddDays(7);
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            hotelEvaluateGridControl.DataSource = HotelEvaluateCtrl.GetHotelEvalAnalysis(tbCitys.Text, tbFromDate.DateTime.ToString("yyyy-MM-dd"), tbToDate.DateTime.ToString("yyyy-MM-dd"));
        }

        private void hotelFeedbackGridView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            if (e.FocusedRowHandle < 0) return;

            string hotelId = hotelEvaluateGridView.GetRowCellValue(e.FocusedRowHandle, "HotelID").ToString();

            hotelEvaluateDetailGridControl.DataSource = HotelEvaluateCtrl.GetHotelEvalAnalysisDetail(hotelId, tbFromDate.DateTime.ToString("yyyy-MM-dd"), tbToDate.DateTime.ToString("yyyy-MM-dd"));
        }
    }
}